import LXCOM from '../../../common/common.js'
var LeftMoseDownTool = {

}

LeftMoseDownTool.action = function (dataManger, mosEvnt, worldPos) {
    var preSelGraph = dataManger.getCurentGraph();
    var pCurentGraph = null;
    pCurentGraph = dataManger.pickGraph(worldPos);
    if (pCurentGraph != null) {
        dataManger.setCurentGraph(pCurentGraph);
        var scaling = dataManger.getScaling();
        var mapscale = dataManger.getMapScale();
        this.selGraphKind(pCurentGraph, worldPos, scaling, mapscale);
    }
    this.chgGraphLight(preSelGraph, pCurentGraph);
    g = 0;
}



LeftMoseDownTool.selGraphKind = function (pGraph, tPoint, scaling, mapscale) {
    var tMakePoint = new LXCOM.LGXPoint();
    tMakePoint.clone(tPoint);
    var selKind = pGraph.calculateSelKind(tMakePoint, scaling, mapscale, false);
    if (selKind > 0) {
        pGraph.setSelect(pGraph.getSelect() + 1);
        pGraph.setSelKind(selKind);
    }
}

LeftMoseDownTool.chgGraphLight = function (preSelGraph, pCurentGraph) {
    if (pCurentGraph != null) {
        pCurentGraph.setSelect(1);
        if (preSelGraph != null && pCurentGraph != preSelGraph) {
            preSelGraph.setSelect(0);
        }
    }
    else {
        if (preSelGraph != null) {
            preSelGraph.setSelect(0);
        }
    }
}
export default { LeftMoseDownTool }